<?php
// 取消预约申请处理
// header("content-type:text/html;charset=UTF-8");
include_once("conn.php");
include_once("u_getLoginInfo.php");
if($status != 1){
    die("<script>alert('账户处于待注销状态，不可操作！');history.go(-1);</script>");
}

$orderID = $_GET['orderID'];

//设置中国时区
date_default_timezone_set('Asia/Shanghai');
// 获取当前日期
$nowDate = date('Y-m-d');

$select = "SELECT * FROM order_infos WHERE orderID = '". $orderID ."'";
$result = mysqli_query($connect_DB, $select);
$row = mysqli_fetch_array($result);
$orderDate = $row['orderDate'];
if($nowDate > $orderDate){
    die("<script>alert('预约日期已过，无法取消预约！请联系管理员！');location.href='user_noworder.php';</script>") ;
}

$sql = "UPDATE order_infos SET orderState = '0' WHERE orderID = '". $orderID ."'";

if(mysqli_query($connect_DB, $sql)){
    echo "<script>alert('取消预约申请成功！');location.href='user_noworder.php';</script>";
}
else{
    echo "<script>alert('取消失败！请稍后重试!');location.href='user_noworder.php';</script>";
}
$connect_DB->close();
?>